package com.wangyadong.hobby.schedule.jobtask.tree.example;

import com.wangyadong.hobby.schedule.jobtask.tree.Position;

/**
 * <p>
 *
 * @author <714037465@qq.com>
 * @since 2018/10/813:01
 **/
public abstract class AbstractTree<E> implements Tree<E> {

    @Override
    public boolean isEmpty() {
        return size() == 0;
    }

    @Override
    public boolean isExternal(Position p) {
        return childNum(p) == 0;
    }

    @Override
    public boolean isInternal(Position position) {
        return childNum(position) > 0;
    }

    @Override
    public boolean isRoot(Position position) {
        return root() == position;
    }
}
